<?php

include_once LIBRARIES_TOOLS . DS . 'XTemplate.php';
include_once LIBRARIES_ENTITIES . DS . 'Database.php';
include_once LIBRARIES_ENTITIES . DS . 'BestSelling.php';

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class BestSellingController
{

    public function ItemBestSellingcontroller()
    {
	try
	{
	    $view = "block/block_itemBestSelling/views/block_itemBestSelling.tpl";
	    $xtemplate = new XTemplate($view);
	    $bestSelling = new BestSelling();
	    $db = new Database();
	    $rs = $bestSelling->getlistBestSelling($db);

	    if ($rs != null)
	    {
		foreach ($rs as $value)
		{
		    $xtemplate->assign("I_ID", $value->I_ID);
		    $xtemplate->assign("I_Alias", $value->I_Alias);
		    $xtemplate->assign("I_Title", $value->I_Title);
		    $xtemplate->assign("I_Price", number_format($value->I_Price, 0, " ", "."));
		    $xtemplate->assign("I_Image", $value->I_Image);
		    $xtemplate->parse("main.ItemList");
		}
	    }
	    $xtemplate->parse("main");
	    $xtemplate->out("main");
	}
	catch (Exception $exc)
	{
	    echo $exc->getTraceAsString();
	}
    }

}

?>
